<?php

// [ 合作机构 ]

namespace app\common\validate;
use think\Validate;

class Agency extends Validate
{
    // 验证规则
    protected $rule = [
        'id'           => 'require|integer|max:11',
        'username'     => 'require|length:4,12',
        'passport'     => 'require|length:4,16',
        'password'     => 'require|length:4,16',
        'confpwd'      => 'require|length:4,16|confirm:password',
        'title'        => 'require|length:2,40',
        'logo'         => 'require|max:256',
        'url'          => 'max:256',
        'introduction' => 'require|max:8000',
    ];

    // 错误提示
    protected $message = [
        'id.require'           => '活动主键必须',
        'id.integer'           => '活动主键必须为数字',
        'id.max'               => '活动主键最大长度[11]',

        'username.require'     => '登录名必须',
        'username.length'      => '登录名长度[2~12]',

        'passport.require'     => '旧登录密码必须',
        'passport.length'      => '旧登录密码长度[4~16]',

        'password.require'     => '登录密码必须',
        'password.length'      => '登录密码长度[4~16]',

        'confpwd.require'      => '确认密码必须',
        'confpwd.length'       => '确认密码长度[4~16]',
        'confpwd.confirm'      => '确认密码与密码不相同',

        'title.require'        => '机构名称必须',
        'title.length'         => '机构名称长度[4~40]',

        'logo.require'         => '机构LOGO必须',
        'logo.max'             => '机构LOGO最大长度[256]',

        'url.max'              => '机构网址最大长度[256]',

        'introduction.require' => '简介必须',
        'introduction.max'     => '简介最大长度[8000]',
    ];

    // 验证场景
    protected $scene = [
        // 新增
        'add'  => ['username','password','title','logo','url','introduction'],
        // 编辑
        'edit' => ['id','username','password','title','logo','url','introduction'],
        // 完善
        'complete' => ['title','logo','url','introduction'],
        // 修改密码
        'updatePwd' => ['passport','password','confpwd'],
    ];
}
